package com.wss.day07;

import java.util.InputMismatchException;
import java.util.Scanner; /**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/4/28
 */


public class ExcetionTest {
    int a;
    int b;
    int c;

    public void performArithmeticOperations() {
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.print("请输入第一个数字: ");
            a = scanner.nextInt();
            System.out.print("请输入第二个数字: ");
            b = scanner.nextInt();

            // 加法运算
            c = a + b;
            System.out.println(a + " + " + b + " = " + c);

            // 减法运算
            c = a - b;
            System.out.println(a + " - " + b + " = " + c);

            // 乘法运算
            c = a * b;
            System.out.println(a + " * " + b + " = " + c);

            // 除法运算
            if (b != 0) {
                c = a / b;
                System.out.println(a + " / " + b + " = " + c);
            } else {
                System.out.println("错误: 除数不能为零。");
            }
        } catch (InputMismatchException e) {
            System.out.println("错误: 输入不是有效的整数。");
        } catch (ArithmeticException e) {
            System.out.println("错误: 发生算术异常，可能是除数为零。");
        } finally {
            scanner.close();
        }
    }

    public void login(String admin, String number) {
    }
}
